package com.pctc.dao;

import com.pctc.model.User;
import org.apache.ibatis.annotations.*;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.annotation.MapperScans;

import java.util.List;


public interface UserMapper {

	@Select("SELECT * FROM USERS WHERE NAME = #{name}")
	public List<User> findByName(@Param("name") String name);

	@Select("SELECT * FROM USERS WHERE id = #{id}")
	public User findById(@Param("id") Integer id);

	@Insert("INSERT INTO USERS(NAME, AGE) VALUES(#{name}, #{age})")
	public int insert(@Param("name") String name, @Param("age") Integer age);


	@Update("update users set name=#{name},age=#{age} where id=#{id}")
	public int updateUser(User user);

	@Delete("delete from users where id=#{id}")
	public int deleteUser(int id);

	@Select("select count(*) from users where id > #{id}")
	@ResultType(int.class)//不写也可以
	public int countUser(int id);



}